<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>微信回调页面</title>
    <script src="./js/plugins/axios.js"></script>
    <script src="./js/plugins/vue.js"></script>
    <script src="./common/common.js"></script>
</head>
<body>
    <div id="app">

    </div>
</body>
<script type="text/javascript">
    alert(location.href)
    new Vue({
        el:"#app",
        mothods:{

        },

        mounted(){
            //从地址栏解析code出来
            let parse = parseUrlParams2Obj(location.href)
            let params = {
                "code": parse.code
            }
            this.$http.post("/login/wechat",params).then(res=>{
                if(res.data.msg == "NoBind"){
                    location.href = "/bind.html?unionid="+res.data.data
                }else {
                    //location.href = "/index.html"
                    localStorage.setItem("token",res.data.data.token);
                    //把对象转换为json字符串存放
                    localStorage.setItem("loginInfo",JSON.stringify(res.data.data.logininfo));
                }
                //分3种情况
                //1.已经注册过且绑定了手机                直接登录  跳转登录页面
                //2.注册过 没有绑定手机                   跳转到绑定手机页面
                //3.没注册过 也没有绑定手机(第一次进入)    跳转注册页面

            })
        },
    })
</script>
</html>